<?php
namespace app\api\controller\v1;

class Bill extends Base{

    public function __construct() {
        parent::__construct();
        $this->checkLogin();
    }

    //交易记录
    public function lists(){
        $d = $this->post();
        $order = 0;
        $page = isset($d['page']) ? (int)$d['page'] : 1;
        $map = [];
        $map[] = ["and","user_id","=",$this->userinfo["id"]];

        $list = m("UserBill","c")->lists($map,0, $page,20);
        $rule = [
            'type' => function($v){return c("type.user_bill_type.{$v}");},
            'withdraw_status' => function($v){return c("type.withdraw_status.{$v}");},
            'create_time' => 'com_date_format',
        ];
        $billlist = com_format($list[0],$rule);
        $list = [
            "list"=>$billlist,
            "max_page"=>ceil($list[1]/20),
            "page_count"=>$list[1],
            "page" => $page
        ];
        suc($list);

    }

}
?>
